package chapter10_compileOptimize;

//swich的语法糖
public class P10_1_2 {

    public static void main(String[] args) {
        int x = 7;
        swInt(x);
    }

    private static void swInt(int x){
        switch (x){
            case 2:
                System.out.println("1");
                break;
            case 3:
                System.out.println("2");
                break;
            case 10:
                System.out.println("5");
                break;
            default:
                System.out.println("未知");
        }
    }
    private static void swStr(String x){
        //注 两个变量如果相等那么hashcode值肯定相等，如果hashcode的值相等变量可能不会相等
        //switch的糖衣下 ，如果是string类型作比较的话，通过比较hashcode然后通过equal来确定switch参数
        switch (x){
            case "zhu":
                System.out.println("1");
                break;
            case "ying":
                System.out.println("2");
                break;
            case "zhi":
                System.out.println("5");
                break;
            default:
                System.out.println("未知");
        }
    }

    enum Type{
        User,Admin
    }
    private static void swEnum(Type type){
        switch (type){
            case User:
                break;
            case Admin:
                break;
            default:
        }
    }
}
